<?php 
// view products

if ($requested == 'changed') {
	$this->pageTitle = 'Updated Products';
} else if ($requested = 'new') {
	$this->pageTitle = 'New Products';
}

?>
<h2><a name="top"><?=count($products)?> Products</a> <?=$html->image('interface/silk/feed.png', array('alt'=>'RSS feed for this page', 'url'=>'/products/view/' . $requested . '.rss'));?></h2>
<?php
if ($requested == 'all') {
	echo '<p>The Full Product Listing</p>';
} else if ($requested == 'changed') {
	echo '<p>Products changed between ', $dates, '</p>';
} else if ($requested == 'new') {
	echo '<p>Products added between ', $dates, '</p>';
}
$open = $this->requestAction('/deliveries/afterOpen');
$m = $this->requestAction('/members/getLoggedInId');
$t = '';
$c = '';
foreach($products as $product) {
	if ($sorting == 'Category') {
		$comp = $product['Category']['category_name'] . ': ' . $product['Subcategory']['subcategory_name'];
		if ($comp != $c) {
			if ($comp == ': ') { $comp = 'Uncategorized'; }
			$c = $comp;
			$t .= '<h4><a name="' . $product['Subcategory']['subcategory_id'] . '">' . $comp . '</a> <a href="#top" class="action">[Back to Top]</a></h4>' . "\n";
			$cats[$product['Subcategory']['subcategory_id']] = $comp;
		}
	}
	$t .= $this->renderElement('product',array('product'=>$product,'open'=>$open,'m'=>$m));
}
if ($sorting == 'Category') {
	echo '<p>Jump to: ';
	$c = array();
	foreach($cats as $id => $cat) {
		$c[] = "<a href='#$id'>$cat</a>";
	}
	echo implode(', ',$c);
	echo '</p>' . "\n";
}
echo $t;

?>
<div style="clear:both"></div>
